from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from .page_base import BasePage
from time import sleep

class CommentPage(BasePage):
    def __init__(self,driver=None):
        super(CommentPage,self).__init__(driver)
        self.switch_to_comment()
        sleep(1)
    
    
    @property
    def sub_title_element(self):
        WebDriverWait(self.driver,3).until(EC.visibility_of_element_located((By.XPATH,"/html/body/div[1]/div/div/div/div[2]/div/main/h3")))
        sub_title = self.find_element(By.XPATH,"/html/body/div[1]/div/div/div/div[2]/div/main/h3")
        return sub_title
    
    
    @property
    def delete_commont_button_element(self):
        return self.find_element(By.XPATH,"/html/body/div/div/div/div/div[2]/div/main/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]/div")
    
    
    @property
    def confirm_delete_commont_button_element(self):
        WebDriverWait(self.driver,3).until(EC.visibility_of_element_located((By.XPATH,"/html/body/div[2]/div/div[2]/div/div/div/div[2]/button[2]/span")))
        return self.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div/div/div/div[2]/button[2]/span")
    
    @property
    def cancel_delete_commont_button_element(self):
        WebDriverWait(self.driver,3).until(EC.visibility_of_element_located((By.XPATH,"/html/body/div[2]/div/div[2]/div/div/div/div[2]/button[1]/span")))
        return self.find_element(By.XPATH,"/html/body/div[2]/div/div[2]/div/div/div/div[2]/button[1]/span")
    

    
    @property
    def info_success_delete_element(self):
        WebDriverWait(self.driver,3).until(EC.visibility_of_element_located((By.XPATH,"/html/body/div[3]/div/div/div/span[2]")))
        return self.find_element(By.XPATH,"/html/body/div[3]/div/div/div/span[2]")
    
    def switch_to_comment(self):
        WebDriverWait(self.driver,3).until(EC.visibility_of_element_located((By.XPATH,"/html/body/div/div/div/div/div[1]/aside/div/ul/li[4]/span")))
        btn = self.find_element(By.XPATH,"/html/body/div/div/div/div/div[1]/aside/div/ul/li[4]/span")
        btn.click()
         
    
    

